﻿#ifndef SOLUTIONWORKER_H
#define SOLUTIONWORKER_H

#include <QObject>
#include <QJsonDocument>
#include <SolutionEntity.h>
class SolutionWorker : public QObject
{
    Q_OBJECT
public:
    explicit SolutionWorker(QString databaseType = "QSQLITE", QString databaseName = "database.db", QObject *parent = nullptr);
    ~SolutionWorker();
public slots:
    void onInit();
protected:
    ///base operate
    QJsonObject readSolution(const QString& name);
    void updateSolution(const QString& name,const QJsonObject& data);
    bool deleteSolution(const QString& name);
    bool createSolution(const QString& name,const QJsonObject& data);
    ///end base operate
    QStringList readAllSolutionName();
    bool renameSolution(const QString& oldName,const QString& newName);
private:
    QJsonObject find(const QString& name);

protected:
    IDatabase* database = nullptr;
    QString m_tableName;
    QString m_databaseType;
    QString m_databaseName;
};

#endif // SOLUTIONWORKER_H
